import 'package:flutter/material.dart';

class MyCustomScrollview extends StatelessWidget {
  const MyCustomScrollview({super.key});

  @override
  Widget build(BuildContext context) {
    return CustomScrollView(
      slivers: [
        // 轮播图
        SliverToBoxAdapter(
          child: Container(
            height: 180,
            color: Colors.blue,
            alignment: Alignment.center,
            child: const Text('轮播图'),
          ),
        ),
        const SliverToBoxAdapter(
          child: SizedBox(
            height: 6,
          ),
        ),
        // 网格布局
        SliverGrid.builder(
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 3,
            mainAxisSpacing: 6,
            crossAxisSpacing: 6,
            childAspectRatio: 1,
          ),
          itemCount: 6,
          itemBuilder: (context, index) {
            return Container(
              alignment: Alignment.center,
              color: Colors.pink,
              child: Text('$index'),
            );
          },
        ),
        // 列表布局
        SliverList.builder(
          itemCount: 6,
          itemBuilder: (context, index) {
            return Container(
              margin: const EdgeInsets.symmetric(vertical: 6),
              height: 100,
              color: Colors.orange,
              alignment: Alignment.center,
              child: Text('$index'),
            );
          },
        ),
      ],
    );
  }
}
